package oj;

import java.util.Scanner;

public class Day23S {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while (sc.hasNext()){
          //动态规划
            String str1=sc.nextLine();
            String str2=sc.nextLine();
            int l1=str1.length();
            int l2=str2.length();
            if(l1*l2==0){
                System.out.println(l1+l2);
            }
            int[][] a=new int[l1+1][l2+1];
            for (int i = 0; i < l1+1; i++) {
                a[i][0]=i;
            }
            for (int i = 0; i < l2+1; i++) {
                a[0][i]=i;
            }
            for (int i = 1; i < l1+1; i++) {
                for (int j = 1; j < l2+1; j++) {
                    if(str1.charAt(i-1)==str2.charAt(j-1)){
                        a[i][j]=Math.min(a[i-1][j-1],Math.min(a[i-1][j]+1,a[i][j-1]+1));
                    }else {
                        a[i][j]=Math.min(a[i-1][j-1]+1,Math.min(a[i-1][j]+1,a[i][j-1]+1));
                    }
                }
            }
            System.out.println(a[l1][l2]);
        }
    }
}
